package com.microtf.inscription.jpa.entity;

import lombok.Data;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import java.util.Date;

/**
 * 博客评论
 *
 * @author guliuzhong
 */
@Data
@Entity
public class BlogComment {
    /**
     * 主键
     */
    @Id
    @SequenceGenerator(sequenceName = "blog_comment_id_seq", name = "genCommentId", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "genCommentId")
    Long id;
    /**
     * 发布人
     */
    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name = "authorId")
    private User author;
    /**
     * 内容
     */
    @Column(length = 1048576, nullable = false)
    private String cont;
    /**
     * 创建时间
     */
    private Date createDate;
    /**
     * 所属的blog
     */
    @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
    private BlogPost blogPost;
}
